<?php
namespace Gigasweb\Email;

use Zend\Mail\Message;
use Zend\Mail\Transport\Sendmail;
use Gigasweb\Email\Template;

class Emailer extends Message {
	var $Template;
	private $Transport;
	

	public function __construct( $charset = 'UTF-8' ) {
		$this->Transport = new Sendmail();
		$this->Template = null;
		//parent::__construct( $charset );
	}
	
	public function setTemplate( Template $template ) {
		$this->Template = $template;
	}
	
	public function setTransport(TransportInterface $transport) {
		$this->Transport = $transport;
	}
	
	public function send() {
		if( $this->Template !== null )
			parent::setBody( $this->Template->compile() );
		return $this->Transport->send($this);
	}
}